{$CLEO .qa}
{$USE CLEO+}
{$USE Audio}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "MicUzi"

// By ArtemQa146

const
    Render_S = 31@
    Render_R = 30@
    Render_O = 29@

    Clip_Model = 27@
    Clip_X = 26@
    Clip_Y = 25@
    Clip_Z = 24@
    Render_S2 = 23@
    Render_R2 = 22@
    Render_O2 = 21@

    Weapon_ID = 28
end

0085: Render_S = 0@ // (int)
0085: Render_R = 1@ // (int)
0085: Render_O = 2@ // (int)
0085: Clip_Model = 3@ // (int)
0085: Clip_X = 4@ // (int)
0085: Clip_Y = 5@ // (int)
0085: Clip_Z = 6@ // (int)
0085: Render_S2 = 7@ // (int)
0085: Render_R2 = 8@ // (int)
0085: Render_O2 = 9@ // (int)

        0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 7@
        0E86: get_weaponinfo_flags 7@ store_to 7@
        if
            7@ == 0x3833
        then
            gosub @Visible_Weapon_Double
        else
            gosub @Visible_Weapon
        end

            repeat
            wait 0
            if and
                not actor.Driving($PLAYER_ACTOR)
                02D8:   actor $PLAYER_ACTOR current_weapon == Weapon_ID
            then
                0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 20@
                0E86: get_weaponinfo_flags 20@ store_to 20@
                if
                    803B:   not 7@ == 20@  // (int)
                then
                    gosub @Hide_Weapon_Double
                    if
                        20@ == 0x3833
                    then
                        gosub @Visible_Weapon_Double
                    else
                        gosub @Visible_Weapon
                    end
                    0085: 7@ = 20@ // (int)
                end
                0A8D: 1@ = read_memory 0xB7CDD0 size 4 virtual_protect 0
                08C3: clear 1@ bit 12
                0A8C: write_memory 0xB7CDD0 size 4 value 1@ virtual_protect 0
                0E35: set_render_object_position Render_O 0 0 0
                0E35: set_render_object_position Render_O2 0.03 0.03 0

                if or
                    Actor.Animation($PLAYER_ACTOR) == "colt45_fire"
                    Actor.Animation($PLAYER_ACTOR) == "colt45_crouchfire"
                    Actor.Animation($PLAYER_ACTOR) == "2guns_crouchfire"
                    Actor.Animation($PLAYER_ACTOR) == "colt45_fire_2hands"
                then
                    if Actor.Animation($PLAYER_ACTOR) == "colt45_fire"
                    then 0613: 1@ = actor $PLAYER_ACTOR animation "colt45_fire" time
                    end
                    if Actor.Animation($PLAYER_ACTOR) == "2guns_crouchfire"
                    then 0613: 1@ = actor $PLAYER_ACTOR animation "2guns_crouchfire" time
                    end
                    if Actor.Animation($PLAYER_ACTOR) == "colt45_crouchfire"
                    then 0613: 1@ = actor $PLAYER_ACTOR animation "colt45_crouchfire" time
                    end
                    if Actor.Animation($PLAYER_ACTOR) == "colt45_fire_2hands"
                    then 0613: 1@ = actor $PLAYER_ACTOR animation "colt45_fire_2hands" time
                    end
                        if and
                            1@ >= 0.3
                            1@ <= 0.95
                        then

                            if and
                                1@ <= 0.5
                                1@ >= 0.3
                            then
                                2@ = 0.298
                                0087: 4@ = 1@ // (float)
                                0063: 4@ -= 2@  // (float)
                                4@ /= 1.0
                                4@ *= -1.0

                                2@ = 0.2995
                                0087: 5@ = 1@ // (float)
                                0063: 5@ -= 2@  // (float)
                                5@ /= 10.0
                                //5@ /= 4.0
                                //5@ *= -1.0

                                2@ = 0.2995
                                0087: 6@ = 1@ // (float)
                                0063: 6@ -= 2@  // (float)
                                6@ /= 1.5
                                6@ /= 10.0
                                6@ *= -1.0
                                if
                                    1@ <= 0.35
                                then
                                    0E35: set_render_object_position Render_O 4@ 5@ 6@
                                    0087: 8@ = 4@ // (float)
                                    0087: 9@ = 5@ // (float)
                                    0087: 11@ = 6@ // (float)
                                    5@ += 0.02
                                    4@ += 0.03
                                    0E35: set_render_object_position Render_O2 4@ 5@ 6@
                                    0087: 16@ = 4@ // (float)
                                    0087: 17@ = 5@ // (float)
                                    0087: 18@ = 6@ // (float)
                                else
                                    0E35: set_render_object_position Render_O 8@ 9@ 11@
                                    0E35: set_render_object_position Render_O2 16@ 17@ 18@
                                    if
                                        1@ >= 0.38
                                    then
                                        0087: 4@ = 1@ // (float)
                                        4@ /= 100.0
                                        005B: 8@ += 4@  // (float)
                                        4@ /= 15.0
                                        0063: 9@ -= 4@  // (float)
                                        005B: 11@ += 4@  // (float)
                                        if 8@ >= 0.0
                                        then 8@ = 0.0
                                        end
                                        if 9@ <= 0.0
                                        then 9@ = 0.0
                                        end
                                        if 11@ >= 0.0
                                        then 11@ = 0.0
                                        end
                                        0087: 16@ = 8@ // (float)
                                        0087: 17@ = 9@ // (float)
                                        0087: 18@ = 10@ // (float)
                                        16@ += 0.03
                                        17@ += 0.02
                                    end
                                end
                            end
                        end
                    end

                    get_char_weapon_clip $PLAYER_ACTOR store_to 0@
                    if and
                        0@ > 0
                        not Actor.Animation($PLAYER_ACTOR) == "colt45_reload"
                        not Actor.Animation($PLAYER_ACTOR) == "colt45_crouchreload"
                    then
                        10@ = 0
                        12@ = 0
                        0E31: set_render_object_visible Render_R 1
                        if
                            7@ == 0x3833
                        then
                            0E31: set_render_object_visible Render_R2 1
                        end
                    end

                        if or
                            Actor.Animation($PLAYER_ACTOR) == "colt45_reload"
                            Actor.Animation($PLAYER_ACTOR) == "colt45_crouchreload"
                        then
                            if Actor.Animation($PLAYER_ACTOR) == "colt45_reload"
                            then 0613: 1@ = actor $PLAYER_ACTOR animation "colt45_reload" time
                            end
                            if Actor.Animation($PLAYER_ACTOR) == "colt45_crouchreload"
                            then 0613: 1@ = actor $PLAYER_ACTOR animation "colt45_crouchreload" time
                            end
                                if and
                                    1@ <= 0.8
                                    1@ >= 0.2
                                then
                                    if and
                                        10@ == 0
                                        1@ <= 0.4
                                    then
                                        10@ = 1
                                        if
                                            12@ == 1
                                        then
                                            0E31: set_render_object_visible Render_R2 0
                                        else
                                            0E31: set_render_object_visible Render_R 0
                                        end
                                        
                                        0A92: stream_custom_script "Clip.qa" Clip_Model Clip_X Clip_Y Clip_Z
                                        
                                        end
                                    end

                                    if and
                                        not 12@ == 1
                                        1@ >= 0.6
                                        1@ <= 0.8
                                    then

                                        if
                                            1@ <= 0.65
                                        then
                                            2@ = 0.595
                                            0087: 4@ = 1@ // (float)
                                            0063: 4@ -= 2@  // (float)
                                            4@ *= -1.0
                                            4@ /= 1.0

                                            2@ = 0.5990
                                            0087: 5@ = 1@ // (float)
                                            0063: 5@ -= 2@  // (float)
                                            5@ /= 10.0
                                            //5@ /= 10.0
                                            //5@ *= -1.0

                                            2@ = 0.5995
                                            0087: 6@ = 1@ // (float)
                                            0063: 6@ -= 2@  // (float)
                                            6@ /= 1.5
                                            6@ /= 10.0
                                            6@ *= -1.0
                                            
                                        end

                                        0E35: set_render_object_position Render_O 4@ 5@ 6@
                                        if
                                            10@ == 1
                                        then
                                            0E31: set_render_object_visible Render_R 1
                                            if
                                                1@ >= 0.75
                                            then
                                                12@ = 1
                                                10@ = 0
                                            end
                                        end
                                    end

                                    if and
                                        12@ == 1
                                        7@ == 0x3833
                                        1@ >= 0.6
                                        1@ < 0.75
                                    then

                                        if
                                            1@ <= 0.65
                                        then
                                            2@ = 0.595
                                            0087: 4@ = 1@ // (float)
                                            0063: 4@ -= 2@  // (float)
                                            4@ *= -1.0
                                            4@ /= 1.0

                                            2@ = 0.5990
                                            0087: 5@ = 1@ // (float)
                                            0063: 5@ -= 2@  // (float)
                                            //5@ /= 2.0
                                            5@ /= 10.0
                                            //5@ *= -1.0

                                            2@ = 0.5995
                                            0087: 6@ = 1@ // (float)
                                            0063: 6@ -= 2@  // (float)
                                            6@ /= 1.5
                                            6@ /= 10.0
                                            6@ *= -1.0
                                            
                                            4@ += 0.03
                                            5@ += 0.02
                                        end

                                        0E35: set_render_object_position Render_O2 4@ 5@ 6@
                                        if
                                            10@ == 1
                                        then
                                            0E31: set_render_object_visible Render_R2 1
                                            if
                                                1@ >= 0.65
                                            then
                                                12@ = 1
                                                10@ = 0
                                            end
                                        end
                                    end

                                end


            else
                break
            end
            until not player.Defined(0)
                0A8D: 1@ = read_memory 0xB7CDD0 size 4 virtual_protect 0
                08BD: set 1@ bit 12
                0A8C: write_memory 0xB7CDD0 size 4 value 1@ virtual_protect 0
            if
                7@ == 0x3833
            then
                gosub @Hide_Weapon_Double
            else
                gosub @Hide_Weapon
            end

0A93: terminate_this_custom_script


:Hide_Weapon
0E31: set_render_object_visible Render_S 0
0E31: set_render_object_visible Render_R 0
0E31: set_render_object_visible Render_O 0
return

:Visible_Weapon
0E31: set_render_object_visible Render_S 1
0E31: set_render_object_visible Render_R 1
0E31: set_render_object_visible Render_O 1
return

:Hide_Weapon_Double
0E31: set_render_object_visible Render_S 0
0E31: set_render_object_visible Render_R 0
0E31: set_render_object_visible Render_O 0
0E31: set_render_object_visible Render_S2 0
0E31: set_render_object_visible Render_R2 0
0E31: set_render_object_visible Render_O2 0
return

:Visible_Weapon_Double
0E31: set_render_object_visible Render_S 1
0E31: set_render_object_visible Render_R 1
0E31: set_render_object_visible Render_O 1
0E31: set_render_object_visible Render_S2 1
0E31: set_render_object_visible Render_R2 1
0E31: set_render_object_visible Render_O2 1
return
